package io.datajek.spring.basics.movierecommendersystem.partone.eleven;

import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class RecommenderImplementation {

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    private Filter filter;

    @Autowired
    public void setFilter(Filter filter){
        logger.info("In RecommenderImplementation setter method..dependency injection");
        this.filter  = filter;
    }

    @PostConstruct
    public void postConstruct(){
        //初始化代码
        logger.info("In RecommenderImplementation postConstruct method");
    }
    @PostConstruct
    public void preDestroy(){
        //清理代码
        logger.info("In RecommenderImplementation postConstruct method");
    }

    @Qualifier("CF")
    //使用过滤器接口选择过滤器
    public Filter contetBaseFilter;
        public String[] recommendMovies (String movie){


            System.out.println("\nName of the filter in use:"+contetBaseFilter+"\n");
            //使用基于内容的过滤表来寻找类似的电影

            //ContentBasedFilter contentBasedFilter = new ContentBasedFilter();
            String[] results = contetBaseFilter.getRecommendations("Finding Dory");

            //返回结果
            // return new String{"M1","M2","M3"};
            return results;

        }
}

